package com.atguigu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.domain.CrmBanner;
import com.atguigu.service.CrmBannerService;
import com.atguigu.mapper.CrmBannerMapper;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Administrator
* @description 针对表【crm_banner(首页banner表)】的数据库操作Service实现
* @createDate 2024-07-03 16:46:03
*/
@Service
public class CrmBannerServiceImpl extends ServiceImpl<CrmBannerMapper, CrmBanner>
    implements CrmBannerService{

    @Cacheable(key = "'selectIndexList'",value = "banner")
    @Override
    public List<CrmBanner> selectAllBanner() {
        QueryWrapper<CrmBanner> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("id");
        //有sql注入风险
        queryWrapper.last("limit 2");
        List<CrmBanner> bannerList = baseMapper.selectList(queryWrapper);
        return bannerList;
    }
}




